﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NextGEN.Util.Portable.Common.Library.Entities.Interfaces;
using NextGEN.Util.Portable.Common.Library.Results;

namespace NextGEN.Util.Portable.Common.Library.Entities.Attributes.ValidationAttributes
{
    public class Required : BasePropertyAttribute, IValidate
    {
        public Required(string propertyName)
            : base(propertyName)
        {
            
        }
        public Required(string propertyName, string propertyMaskName, bool isWorkedAuto)
            : base(propertyName, propertyMaskName, isWorkedAuto)
        {
            
        }

        public ValidationResult IsValid(object value)
        {
            if (value != null)
            {
                return new ValidationResult();
            }
            Debug.Assert(value != null, "value != null");
            return
                new ValidationResult(new[]
                {
                    string.Format("{0} değeri girilmelidir.", PropertyMaskName ?? PropertyName)
                });
        }
    }
}
